<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('用料采购申请列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
<!--                            <li>-->
<!--                                <label>材料类型：</label>-->
<!--                                <input type="text" name="mName"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>材料数量：</label>-->
<!--                                <input type="text" name="mNum"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>项目外键：</label>-->
<!--                                <input type="text" name="mId"/>-->
<!--                            </li>-->
                            <li>
                                <label>项目名称：</label>
                                <input type="text" name="pName"/>
                            </li>
                            <li class="select-time">
                                <label>创建时间：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginPTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endPTime]"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
     <th:block th:include="include :: footer" />
     <script th:inline="javascript">
         var removeFlag = [[${@permission.hasPermi('ruoyi:requisition:remove')}]];
         var editFlag = [[${@permission.hasPermi('ruoyi:requisition:edit')}]]
         var creadFlag = [[${@permission.hasPermi('ruoyi:requisition:add')}]];
         //工程文件字典类型
         var beType = [[${@dict.getType('sys_be_type')}]];
         //审批状态字典
         var mStatus = [[${@dict.getType('mate_status')}]];
         var prefix = ctx + "system/building";
         var prefixs = ctx + "ruoyi/requisitionVerify";


         $(function() {
             var options = {
                 url: prefix + "/list",
                 createUrl: prefixs + "/add/{id}",
                 exportUrl: prefix + "/export",
                 removeUrl: prefixs + "/remove",
                 updateUrl: prefixs + "/edit/{id}",
                 modalName:"",
                 showSearch: false,
                 showRefresh: false,
                 showToggle: false,
                 showColumns: false,
                 detailView: true,
                 onExpandRow: function (index, row, $building) {
                     initChildTable(index, row, $building);
                 },

                 columns: [{
                     checkbox: true
                 },
                     {
                         field: 'pId',
                         title: '项目id',
                         visible: false
                     },
                     {
                         field: 'pName',
                         title: '项目名称'
                     },
                     {
                         field: 'pTime',
                         title: '项目日期'
                     },
                     {
                         field: 'pFounder',
                         title: '项目经理'
                     },
                 ]
             };
             $.table.init(options);
         });

         initChildTable = function (index, row, $building) {
             var childTable = $building.html('<table style="table-layout:fixed"></table>').find('table');
             $(childTable).bootstrapTable({
                 url: prefixs  + "/list",
                 method: 'post',
                 sidePagination: "server",
                 contentType: "application/x-www-form-urlencoded",
                 queryParams: {
                     sid:row.pId
                 },
                 columns: [
                     {
                         field: 'id',
                         title: '材料id',
                         visible: false
                     },
                     {
                         field: 'mName',
                         title: '材料类型'
                     },
                     {
                         field: 'mNum',
                         title: '材料数量',
                     },
                     {
                         field: 'mApplicant',
                         title: '申请人'
                     },
                     {
                         field: 'mTime',
                         title: '创建时间'
                     },
                     {
                         field: 'mStatus',
                         title: '审批状态',
                         formatter: function(value, row, index) {
                             return $.table.selectDictLabel(mStatus, value);
                         }
                     },
                     {
                         field: 'mId',
                         title: '项目外键',
                         visible: false

                     },
                     {
                         field: 'mOpinion',
                         title: '审批意见',
                     },
                     {
                         title: '操作',
                         align: 'center',
                         formatter: function (value, row, index) {
                             var actions = [];
                             if (row.mStatus==1){
                                 actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="consent(\'' + row.id + '\')"><i class="fa fa-user"></i> 通过</a> ');
                                 actions.push('<a class="btn btn-warning btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>驳回</a> ');
                             }
                             return actions.join('');
                         }
                     }

                 ]
             });
         };
         function consent(id) {

             $.modal.confirm("确认要通过申请吗?", function() {
                 var url = prefixs + "/consent";
                 var data = { "id": id };
                 $.operate.submit(url, "post", "json", data);
             });
         }
     </script>
</body>
</html>